import 'core-js'
import express from 'express'
import path from 'path'
import { ENV } from '@server/env'
import morgan from 'morgan'
import fileUpload from 'express-fileupload'
import { errorHandler } from './error/error-handler'
import { api } from './api'

const app = express()
app.use(express.static(path.resolve('./www')))
app.use(express.json())
app.use(morgan('dev'))
app.use(fileUpload())
api(app)
app.use(errorHandler)
// 启动服务器
app.listen(ENV.PORT, () => {
  console.log(`server is running on port ${ENV.PORT}`)
})
